package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/resp")
public class ResponseServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 1.设置相应内容
		resp.setContentType("text/html;charset=utf-8");
		// 2.设置字符编码
		resp.setCharacterEncoding("utf-8");
		// 3.得到输出流 
		PrintWriter out = resp.getWriter();
		// 4.往外写
		out.write("<h1>服务器收到你的请求了</h1>");
		// 5.刷新
		out.flush();
	}
}
